(function() {
	Path.on("/__basename__.html", function() {});
	//百度地图
	require(["baiduMap"], function(baiduMap) {
		baiduMap(function init_map() {
			// 百度地图API功能
			var map = new BMap.Map("map"); // 创建Map实例
			map.addControl(new BMap.NavigationControl()); // 添加平移缩放控件
			map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
			map.enableScrollWheelZoom(); //启用滚轮放大缩小
			map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
			var localSearch = new BMap.LocalSearch(map); //搜索实例 
			var ownLbs = App.get("bus_info.info.lbs_info");
			var mkr; //标注点容器
			var logostr; //logo路径
			if (App.get("bus_info.info.lgo_url")) {
				logostr = App.get("bus_info.info.lgo_url") + "?imageView/2/w/60";
			} else {
				logostr = "/images/logo.png";
			};
			var infoWindow = new BMap.InfoWindow("<img style='width:60px;height:60px;margin-right:5px;vertical-align:top;display:inline-block' src='" + logostr + "' id='imgDemo'/><span style='width:135px;display:inline-block;vertical-align:top;white-space: normal;word-spacing: normal;word-wrap:break-word;word-break:break-all;'>" + App.get("bus_info.info.address") + "</span>", {
				width: 200, // 信息窗口宽度
				title: App.get("bus_info.info.title"), // 信息窗口标题
				enableMessage: true, //设置允许信息窗发送短息
				message: "这个店铺不错哦，一起分享吧！"
			}); //信息窗口容器
			if (ownLbs) {
				lbsPoint = new BMap.Point(ownLbs.lng, ownLbs.lat);
				mkr = new BMap.Marker(lbsPoint);
				map.centerAndZoom(lbsPoint, 15);
				map.addOverlay(mkr);
				map.openInfoWindow(infoWindow, lbsPoint);
			} else {
				showMap(App.get("bus_info.info.address"));
			};

			function showMap(cityName) {
				localSearch.setSearchCompleteCallback(function(searchResult) {
					var poi = searchResult.getPoi(0);
					if (!poi) {
						alert("warn", "抱歉，暂时找不到该店铺的位置！！");
						return;
					}
					var center = new BMap.Point(poi.point.lng, poi.point.lat);
					map.centerAndZoom(center, 15);
					mkr = new BMap.Marker(center);
					map.addOverlay(mkr);
					map.openInfoWindow(infoWindow, center);
				});
				localSearch.search(cityName);
			}
		});
	});


	if (App.get('bus_info.info.open_time.s_min') < 10) {
		App.set('bus_info.info.open_time.s_min', '0' + App.get('bus_info.info.open_time.s_min'));
	};
	if (App.get('bus_info.info.open_time.e_min') < 10) {
		App.set('bus_info.info.open_time.e_min', '0' + App.get('bus_info.info.open_time.e_min'));
	};

	App.set('$Event.storeinfo.showStoreImg', function(e, vm) {
		console.log(vm.get("href"));
		vm.set("$Private.aa", "sdads");
		if (App.get('$Cache.storeinfo.imgPrivate')) {
			App.set('$Cache.storeinfo.imgPrivate', '');
		} else {
			App.set('$Cache.storeinfo.imgPrivate', 'focus');
		}
	});
	App.set('$Event.storeinfo.showBigImg', function(e, vm) {
		console.log(vm.get('$Index'));
		vm.model.toggle('$Cache.storeinfo.iPrivate');
		App.model.toggle('$Cache.storeinfo.blockimg');
	});
}());